package com.homedo.odin.solution.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.homedo.core.common.base.service.BaseService;
import com.homedo.odin.solution.dao.UserPayOrderMapper;
import com.homedo.odin.solution.model.dto.PageBean;
import com.homedo.odin.solution.model.entity.UserPayOrder;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * <p> 用户支付订单表 服务实现类 </p>
 *
 * @author HarveyDing
 * @since 2018-03-08
 */
@Service
public class UserPayOrderServiceImpl extends BaseService<UserPayOrderMapper, UserPayOrder> {

    public UserPayOrder queryUserPayOrder(Long businessId, Integer uid) {
        return baseMapper.queryUserPayOrder(businessId, uid);
    }

    public List<UserPayOrder> queryOrderByBusinessId(Long businessId, Integer businessType, Integer status) {
        return baseMapper.queryOrderByBusinessId(businessId, businessType, status);
    }

    public Integer queryFreeSolutionDownloadCount(Integer userId, Integer actionType) {
        return baseMapper.queryFreeSolutionDownloadCount(userId, actionType);
    }

    public PageInfo<UserPayOrder> queryFinancialListForPri(Integer businessType, Date createStartDate,
            Date createEndDate, PageBean pageBean) {
        PageHelper.startPage(pageBean.getCurrentPage(), pageBean.getPageSize());
        return new PageInfo<UserPayOrder>(
                baseMapper.queryFinancialListForPri(businessType, createStartDate, createEndDate));
    }

    public BigDecimal queryFinancialCount() {
        return baseMapper.queryFinancialCount();
    }

    public UserPayOrder getPayOrderByOrderNo(Long orderNo) {
        return baseMapper.getPayOrderByOrderNo(orderNo);

    }

    public Integer updateOrderStatus(Long orderNo, Integer status) {
        return baseMapper.updateOrderStatus(orderNo, status);
    }

    public Integer updatePayModel(Long orderNo, Integer payMode) {
        return baseMapper.updatePayModel(orderNo, payMode);
    }

    public Integer insertPayOrder(UserPayOrder userPayOrder) {
        return baseMapper.insert(userPayOrder);
    }

    public void updateOrder(UserPayOrder userPayOrder) {
        baseMapper.updateById(userPayOrder);
    }
}
